package com.nulstudio.sppm.network;

import java.util.Objects;

public final class Request<T> {
    private final int version;

    private final T request;

    public Request(int version, T request) {
        this.version = version;
        this.request = request;
    }

    public Request() {
        this.version = 0;
        this.request = null;
    }

    public int getVersion() {
        return version;
    }

    public T getRequest() {
        return request;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Request<?> request1 = (Request<?>) o;
        return version == request1.version && Objects.equals(request, request1.request);
    }

    @Override
    public int hashCode() {
        return Objects.hash(version, request);
    }
}
